package com.atguigu.lease.app.controller;

import com.atguigu.lease.app.mapper.RoomPaymentTypeMapper;
import com.atguigu.lease.app.service.PaymentTypeService;
import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.bean.PaymentType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name="支付方式模块")
@RequestMapping("/app/payment")
@RestController
public class PaymentController {
    @Autowired
    PaymentTypeService paymentTypeService;
    @Autowired
    RoomPaymentTypeMapper roomPaymentTypeMapper;

    @Operation(summary = "查询所有的支付方式")
    @GetMapping("/list")
    public Result list(){
        return Result.ok(paymentTypeService.list());
    }
    
    ///app/payment/listByRoomId
    @Operation(summary = "根据房间id查询租期列表")
    @GetMapping("listByRoomId")
    public Result listByRoomId(@RequestParam Long id){
        List<PaymentType> paymentTypes = roomPaymentTypeMapper.selectPaymentTypesByRoomId(id);
        return Result.ok(paymentTypes);
    }

}
